﻿@{
    ViewBag.Title = "Gestão de Parâmetros";
}

@{
    int idP = 0;
    
    if (!String.IsNullOrEmpty(ViewBag.IdParam))
    {
        idP = ViewBag.IdParam;
    }

}

<h4><i class="fa fa-cog" style="margin-top: 3px;"></i> @ViewBag.Title</h4>

<div class="input-prepend">
    <span class="add-on"><b>PARÂMETRO</b>&nbsp;</span>
    <div class="input-append">
        @Html.DropDownList("Parameters",null , new {@classe="form-control", @style="width: 300px !important;  height: 30px !important;"})
    </div>
</div>

<br/><br/>

<div class="row-fluid">
    <div id="panelLeft"class="span6" style="position: relative;">
        <div id="listParam">
            @Html.Partial("_DefaultLeft")
        </div>
        <div id="feedbackMsg">
           
        </div>
    </div>
    <div id="panelRight" class="span6">
        <div id="formParam">
            @Html.Partial("_DefaultRight")        
        </div>    
    </div>
</div>


@*@Scripts.Render("~/bundles/culturam") *@

<script>
    $('#Parameters').on('change', function () {
        //Update Left Panel
        //var e = document.getElementById("DdlParameter");
        //var ddlParam = e.options[e.selectedIndex].value;

        var ddlParam = 0;
        $("#Parameters option:selected").each(function () {
            ddlParam = $(this).val();
        });

        //alert("ID PARAM.: " + ddlParam);

        $.ajax({
            url: '/Parameters/ListParameters',
            dataType: 'html',
            type: 'GET',
            data: { idParam: ddlParam, page: "1" },

            success: function (data) {
                jQuery.validator.unobtrusive.parse('#listParam');
                $('#listParam').html(data);
            },
            error: function () {
                alert("ERRO: ao tentar abrir formulário...");
            }
        });

        //Update Right Panel
        $.ajax({
            url: '/Parameters/DefaultRight',
            dataType: 'html',
            type: 'GET',
            data: { idParam: ddlParam },
            success: function (data) {
                jQuery.validator.unobtrusive.parse('#formParam');
                $('#formParam').html(data);
            },
            error: function () {
                alert("ERRO: ao tentar abrir formulário...");
            }
        });

    });

</script>
